package com.linfeng.component.common.enums;

import com.linfeng.component.common.exception.CustomException;
import com.linfeng.component.common.exception.CustomExceptionCode;

import java.util.Arrays;

public enum SexEnum {

    MEN(1, "男"),
    WOMEN(2, "女");

    private Integer index;

    private String display;

    SexEnum(Integer index, String display) {
        this.index = index;
        this.display = display;
    }

    public Integer getIndex() {
        return index;
    }

    public void setIndex(Integer index) {
        this.index = index;
    }

    public String getDisplay() {
        return display;
    }

    public void setDisplay(String display) {
        this.display = display;
    }

    public static String getDisplay(Integer index) {


        return Arrays.stream(SexEnum.values())
                .filter(obj -> obj.index.equals(index))
                .findFirst()
                .orElseThrow(() -> new CustomException(CustomExceptionCode.SYSTEM_NOT_FOUND))
                .getDisplay();
    }
}
